/**
 * 0. Project	: com.dnbns.lib 프로젝트
 *
 * 1. FileName	: PushWakeLock.java
 * 2. Package	: com.dnbns.lib
 * 3. 작성자		: 윤화현
 * 4. 작성일		: 2014. 1. 21. 오전 11:43:38
 * 5. Comment	: 
 */

package com.dnbns.lib;

import android.content.Context;
import android.os.PowerManager;
import android.util.Log;

public class PushWakeLock {     
    private static PowerManager.WakeLock sCpuWakeLock;    
     
    @SuppressWarnings("deprecation")
	public static void acquireCpuWakeLock(Context context) {        
        Log.e("PushWakeLock", "Acquiring cpu wake lock");        
        Log.e("PushWakeLock", "wake sCpuWakeLock = " + sCpuWakeLock);        
         
        if (sCpuWakeLock != null) {            
            return;        
        }         
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);         
        sCpuWakeLock = pm.newWakeLock(                
                PowerManager.SCREEN_BRIGHT_WAKE_LOCK |                
                PowerManager.ACQUIRE_CAUSES_WAKEUP |                
                PowerManager.ON_AFTER_RELEASE, "hello");        
         
        sCpuWakeLock.acquire();        
    }
     
    public static void releaseCpuLock() {        
        Log.e("PushWakeLock", "Releasing cpu wake lock");
        Log.e("PushWakeLock", "relase sCpuWakeLock = " + sCpuWakeLock);
         
        if (sCpuWakeLock != null) {            
            sCpuWakeLock.release();            
            sCpuWakeLock = null;        
        }    
    }
}